package variabilitysmelldetection.measurement.measures.spl;

import java.util.List;

import variabilitysmelldetection.measurement.measures.Measure;
import variabilitysmelldetection.measurement.measures.component.NumberOfOperationOverrides;
import variabilitysmelldetection.measurement.models.ComponentItem;
import variabilitysmelldetection.measurement.models.MethodItem;



public class NumberOfOverriddenOperations extends Measure {

	public NumberOfOverriddenOperations() {
		super("Number of Overridden Operations", "NOrO");
	}

	public void measure(List<ComponentItem> items){
		int numOfOverridenOperations = 0;
		for (ComponentItem classe : items) {

			List<MethodItem> methods = classe.getMethods();

			for (MethodItem method : methods) {

				if (!method.isRefinement()) {
					
					Measure measure = method.getMeasure(NumberOfOperationOverrides.class);
					if ((measure != null) && (measure.getValue() > 0)) {
						numOfOverridenOperations++;		
					}
				}
			}
		}
		setValue(numOfOverridenOperations);
	}
}
